package com.zetxek.meteogalicia.datasets;

import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public /*abstract*/ class Prediccion {
	/**
	 * Clase abstracta con los datos comunes a las predicciones inmediatas y a medio plazo
	 */
	private SimpleDateFormat FORMATTER = new SimpleDateFormat(
			"yyyy-MM-ddHH:mm:ss");
	private String title;
	private URL link;
	private String description;
	private Date pubDate;
	private URL guid;
	/*
	 * Prediccion corto plazo
	 */
	private String comentario;
	private String nomeZona;
	private String idZona;
	private Date dataCreacion;
	private Date dataPred;
	private Integer TMax;
	private Integer TMin;
	private String ceoM;
	private String ceoT;
	private String ceoN;
	private String ventoM;
	private String ventoT;
	private String ventoN;
/* 
 * Prediccion medio plazo 
 */
//	private String comentario;
//	private String nomeZona;
//	private String idZona;
//	private Date dataCreacion;
	private Date dataPredicion;
	private String estadoCeo;
	private int pCep;
	private int tendenciaTMax;
	private int tendenciaTMin;
	private int pChuvia;
	private int tChuvia;
	private int pVento;

	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public URL getLink() {
		return link;
	}

	public void setLink(String link) {
		try {
			this.link = new URL(link);
		} catch (MalformedURLException e) {
			throw new RuntimeException(e);
		}
	}
	
	public URL getGuid() {
		return guid;
	}

	public void setGuid(String link) {
		try {
			this.guid = new URL(link);
		} catch (MalformedURLException e) {
			throw new RuntimeException(e);
		}
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getPubDate() {
		return pubDate;
	}

	public void setPubDate(String date) {
		// pad the date if necessary
		while (!date.endsWith("00")){
			date += "0";
		}
		try {
			this.pubDate = FORMATTER.parse(date.trim());
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}	}
	

	public SimpleDateFormat getFORMATTER() {
		return FORMATTER;
	}

	public void setFORMATTER(SimpleDateFormat formatter) {
		FORMATTER = formatter;
	}

	public void setLink(URL link) {
		this.link = link;
	}

	public void setPubDate(Date pubDate) {
		this.pubDate = pubDate;
	}

	public void setGuid(URL guid) {
		this.guid = guid;
	}
/*
 * Corto plazo
 */
	public String getComentario() {
		return comentario;
	}

	public void setComentario(String comentario) {
		this.comentario = comentario;
	}

	public String getNomeZona() {
		return nomeZona;
	}

	public void setNomeZona(String nomeZona) {
		this.nomeZona = nomeZona;
	}

	public String getIdZona() {
		return idZona;
	}

	public void setIdZona(String idZona) {
		this.idZona = idZona;
	}

	public Date getDataCreacion() {
		return dataCreacion;
	}

	public void setDataCreacion(Date dataCreacion) {
		this.dataCreacion = dataCreacion;
	}
	
	public void setDataCreacion(String date) {
		// pad the date if necessary
		while (!date.endsWith("00")){
			date += "0";
		}
		try {
			this.dataCreacion = getFORMATTER().parse(date.trim());
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}	}
	

	public Date getDataPred() {
		return dataPred;
	}

	public void setDataPred(Date dataPred) {
		this.dataPred = dataPred;
	}
	
	public void setDataPred(String date) {
		// pad the date if necessary
		while (!date.endsWith("00")){
			date += "0";
		}
		try {
			this.dataPred = getFORMATTER().parse(date.trim());
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}	}
	

	public Integer getTMax() {
		return TMax;
	}

	public void setTMax(Integer max) {
		TMax = max;
	}

	public Integer getTMin() {
		return TMin;
	}

	public void setTMin(Integer min) {
		TMin = min;
	}

	public String getCeoM() {
		return ceoM;
	}

	public void setCeoM(String ceoM) {
		this.ceoM = ceoM;
	}

	public String getCeoT() {
		return ceoT;
	}

	public void setCeoT(String ceoT) {
		this.ceoT = ceoT;
	}

	public String getCeoN() {
		return ceoN;
	}

	public void setCeoN(String ceoN) {
		this.ceoN = ceoN;
	}

	public String getVentoM() {
		return ventoM;
	}

	public void setVentoM(String ventoM) {
		this.ventoM = ventoM;
	}

	public String getVentoT() {
		return ventoT;
	}

	public void setVentoT(String ventoT) {
		this.ventoT = ventoT;
	}

	public String getVentoN() {
		return ventoN;
	}

	public void setVentoN(String ventoN) {
		this.ventoN = ventoN;
	}

	/*
	 * Medio plazo
	 */
	public void setDataPredicion(String date) {
		// pad the date if necessary
		while (!date.endsWith("00")) {
			date += "0";
		}
		try {
			this.dataPredicion = getFORMATTER().parse(date.trim());
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
	}

	public Date getDataPredicion() {
		return dataPredicion;
	}

	public void setDataPredicion(Date dataPredicion) {
		this.dataPredicion = dataPredicion;
	}

	public String getEstadoCeo() {
		return estadoCeo;
	}

	public void setEstadoCeo(String estadoCeo) {
		this.estadoCeo = estadoCeo;
	}

	public int getPCep() {
		return pCep;
	}

	public void setPCep(int cep) {
		pCep = cep;
	}

	public int getTendenciaTMax() {
		return tendenciaTMax;
	}

	public void setTendenciaTMax(int tendenciaTMax) {
		this.tendenciaTMax = tendenciaTMax;
	}

	public int getTendenciaTMin() {
		return tendenciaTMin;
	}

	public void setTendenciaTMin(int tendenciaTMin) {
		this.tendenciaTMin = tendenciaTMin;
	}

	public int getPChuvia() {
		return pChuvia;
	}

	public void setPChuvia(int chuvia) {
		pChuvia = chuvia;
	}

	public int getTChuvia() {
		return tChuvia;
	}

	public void setTChuvia(int chuvia) {
		tChuvia = chuvia;
	}

	public int getPVento() {
		return pVento;
	}

	public void setPVento(int vento) {
		pVento = vento;
	}
}
